package com.gitee.wsl.resource.font

import androidx.compose.ui.text.font.Font
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.FontResource
import org.jetbrains.compose.resources.ResourceEnvironment
import org.jetbrains.compose.resources.getFontResourceBytes
@OptIn(markerClass = [ExperimentalResourceApi::class])
internal actual suspend fun loadFont(
    environment: ResourceEnvironment,
    font: FontSpec,
    resource: FontResource,
): Font {
    return androidx.compose.ui.text.platform.Font(
        identity = "${font.family}_${font.weight.weight}_${font.style}",
        data = getFontResourceBytes(environment, resource),
        weight = font.weight,
        style = font.style
    )
}
